<template>
	<view class="content">
		<view class="box">
			<view class="card2" v-if="pageStatus === '1'">
				<text class="cardname">融通卡</text>
				<text>{{cardNum}}</text>
			</view>
			<view class="card1" v-else>
				<view class="bg" ></view>
				<text class="title" @click="getcard">{{title}}</text>
			</view>
			<button v-if="pageStatus === '1'" type="default" @click="submit" >点我去扫码</button>
		</view>
	</view>
</template>

<script>
	import uniData from './uni.webview.1.5.2.js'
	export default {
		data() {
			return {
				title: '申请',
				pageStatus: '0',
				cardNum:'',
				paraString: '',
				verify_token: ''
				
			}
		},
		onLoad(option) {
			this.getvtoken();
			this.paraString = window.location.href
			this.pageStatus = option.pageStatus //code是url后面带的
			this.cardNum = option.idcard
			 // console.log(this.pageStatus)
			 // console.log(this.this.cardNum)
			 //  if(this.pageStatus === '1') {
				//  // 调取成功的接口
				//  this.getNumber();
			 // }
		},
		methods: {
			getvtoken() {
				this.$api.getvtoken({
				}).then(value => {
						// console.log(value)
						let data =  JSON.parse(value);
						// console.log(data)
						this.verify_token = data.result.verify_token;
						 // console.log(this.verify_token)
					    uni.setStorageSync('vtoken', this.verify_token);
						//业务代码 使用数据
					}).catch(err => {
						 this.$toast(err)
					})
			},
			// successStatus() {
			// 	let  vtoken = uni.getStorageSync('vtoken');
			// 	this.$api.successStatus( {
			// 		//vtoken 代表是哪次的OCR识别
			// 		vtoken: '',
					
			// 	})
			// },
			getcard(){
					 let vtoken = this.verify_token
					let successUrl = 'http://49.232.89.149/pages/identity/identity'
					let failedUrl = 'http://49.232.89.149/pages/index/index?pageStatus=0'
					window.location.href= `https://brain.baidu.com/face/print/statement/statement?token=${vtoken}&successUrl=${successUrl}&failedUrl=${failedUrl}`
			},
			
			
			// getNumber(){
			// 	// let id = uni.getStorageSync('id');
			// 	this.$api.cardNumber({
			// 		option
			// 		// 用户id
			// 		id:id,
			// 		// 身份类型
			// 		cardType:cardType, //
			// 		// 用户等级
			// 		level:A,  //A B C
			// 		// 状态
			// 		status:1//1启用  2停用
			// 	}).then(value =>{
					
			// 	})
			// },
			scanqrcode() {
				let that = this
				uni.scanCode({
					success: function (res) {
						   that.$toast(res.result)
					        console.log('条码类型：' + res.scanType);
					        console.log('条码内容：' + res.result);
							 uni.navigateTo({
							 	url:'/pages/scan/authorization'
							 })
					    }
				})
			},
			submit(){
				uni.webView.navigateTo({
				       url:'/pages/scan/scan',
				       animationType:'pop-in',
				       animationDuration:300
				    })
			}
		}
	}
</script>

<style lang="scss">
	.content{
		width: 750rpx;
		height: 100%;
		.box{
			margin: 50rpx auto;
			position: relative;
			.card1{
				display: flex;
				.bg {
					margin: 20rpx 30rpx;
					width: 460rpx;
					height: 300rpx;
					background-color: blue;
				}
				.title{
					padding-top: 160rpx;
					padding-left: 60rpx;
					font-size: 50rpx;
					
				}
			}
			.card2{
				margin: 50rpx 100rpx;
				padding: 50rpx 30rpx;
				width: 480rpx;
				height: 310rpx;
			    background-color: red;
				text{
					padding: 100rpx 30rpx;
					text-align: center;
					font-size: 30rpx;
				}
				text:nth-child(1){
					font-size: 50rpx;
				}
			
			}
			.scanrq{
				position: absolute;
			    top:800rpx;
				left: 500rpx;
				margin: 100rpx auto;
				width: 200rpx;
				height: 200rpx;
				text{
					font-size: 30rpx;
					font-weight: 600;
				}
				image{
					width: 150rpx;
					height: 150rpx;
				}
			}
				
		}
		
	}
</style>
